from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet

from meiduo_admin.serializers.specs import SpecsSerialzier, SPUSerializer
from goods.models import SPUSpecification,SPU

# 规格增删改查
from meiduo_admin.utils import PageNum


class SpecsView(ModelViewSet):
    serializer_class = SpecsSerialzier
    queryset = SPUSpecification.objects.all()
    pagination_class = PageNum

    def simple(self,request):
        """
        获取SPU表信息
        :param request:
        :return:
        """
        # 查询spu表信息
        spus = SPU.objects.all()
        # spu序列化返回
        ser = SPUSerializer(spus,many=True)
        return Response(ser.data)


